import request from '@/utils/request'

// 初始化分片上传
export function initMultiPartUpload(fileName, chunkCount) {
  return request({
    url: '/minio/init',
    method: 'post',
    params: {
      fileName,
      chunkCount
    }
  })
}

// 上传分片
export function uploadChunk(data) {
  return request({
    url: '/minio/uploadChunk',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 合并分片
export function mergeChunks(fileIdentifier, fileName, chunkCount) {
  return request({
    url: '/minio/merge',
    method: 'post',
    params: {
      fileIdentifier,
      fileName,
      chunkCount
    }
  })
}

// 检查分片是否存在
export function checkChunk(fileIdentifier, chunkIndex) {
  return request({
    url: '/minio/checkChunk',
    method: 'get',
    params: {
      fileIdentifier,
      chunkIndex
    }
  })
}